package org.coco.mvc.render.impl;

import org.coco.mvc.RequestProcessorChain;
import org.coco.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * 默认渲染器，当用户请求不需要获取请求结果的时候，就默认调用这个渲染器
 */
public class DefaultResultRender implements ResultRender {
    @Override
    public void render(RequestProcessorChain requestProcessorChain) throws Exception {
        PrintWriter writer = null;
        try {
            //就返回状态码
            HttpServletResponse response = requestProcessorChain.getResponse();
            int status = response.getStatus();
            writer = response.getWriter();
            writer.write(status);
            writer.flush();
        }finally {
            writer.close();
        }
        
    }
}
